package com.guice.web.guice_webapp_example;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import com.guice.web.guice_webapp_example.mybatis.MybatisModule;
import com.guice.web.guice_webapp_example.quartz.QuartzModule;
import com.guice.web.guice_webapp_example.quartz.jobs.Myjob;
import com.guice.web.guice_webapp_example.servlet.IndexServlet;
import com.guice.web.guice_webapp_example.servlet.UserServlet;

public class ServletConfig extends GuiceServletContextListener {
    @Override
    protected Injector getInjector() {
        return Guice.createInjector(new MybatisModule(),new ServletModule() {
            @Override
            protected void configureServlets() {
                super.configureServlets();
                serve("/test").with(TestServlet.class);
                serve("/index").with(IndexServlet.class);
                serve("/user").with(UserServlet.class);
                bind(String.class).toInstance("Hello, World!");
            }
        }, new QuartzModule() {
            @Override
            protected void schedule() {
                scheduleJob(Myjob.class);
            }
      });
    }
}
